const io = require("socket.io-client");
const socket = io("http://localhost:3000", {
    withCredentials: true,
    extraHeaders: {
        "my-custom-header": "abcd"
    },
    // auth: (cb) => {
    //     cb("token");
    // }
});

socket.io.on("reconnect_attempt", () => {
    // ...
});

socket.io.on("reconnect", () => {
    // ...
});

// GOOD
socket.on("connect", () => {
    // ...
    socket.emit("data", "hello world.");
});

socket.on("data", (arg) => { 
    console.log(`server data: ${arg}`);
});

socket.on("disconnect", (reason) => {
    // ...
});

socket.on("connect_error", () => {
    setTimeout(() => {
        socket.connect();
    }, 1000);
});